package com.jsu.information.controller.v1;

import com.jsu.information.service.InformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.model.common.dtos.ResponseResult;
import org.example.model.information.pojo.Information;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/information/information")
@Api(tags = "资讯相关接口")
public class InformationController {
    @Autowired
    private InformationService informationService;

    @GetMapping("/getUrl")
    @ApiOperation(value = "获取资讯视频地址")
    public ResponseResult getUrl(Integer informationId){
        return informationService.getUrl(informationId);
    }

    @PostMapping("/addInfo")
    @ApiOperation(value = "新增数据库视频资讯信息")
    public ResponseResult addInfo(@RequestBody Information information){
        return informationService.addInfo(information);
    }

    @DeleteMapping("/delInfo")
    @ApiOperation(value = "删除数据库视频资讯信息")
    public ResponseResult delInfo(Integer informationId){
        return informationService.delInfo(informationId);
    }

    @GetMapping("/getAllInfos")
    @ApiOperation(value = "获取数据库视频资讯信息")
    public ResponseResult getAllInfos(List<Integer> informationId){

        return informationService.getAllInfos(informationId);
    }


    @PutMapping("/addViews")
    @ApiOperation(value = "新增浏览量")
    public ResponseResult addViews(Integer informationId){
        return informationService.addViews(informationId);
    }

    @PostMapping("/addUserLikes")
    @ApiOperation(value = "新增点赞")
    public ResponseResult addLikes(Integer informationId,Integer userId){
        return informationService.addLikes(informationId,userId);
    }

    @GetMapping("/getUserLikes")
    @ApiOperation(value = "查询该资讯点赞，返回1表示点了赞，返回0表示未点赞")
    public ResponseResult getUserLikes(Integer informationId,Integer userId){
        return informationService.getUserLikes(informationId,userId);
    }

    @DeleteMapping("/delUserLikes")
    @ApiOperation(value = "用户取消点赞")
    public ResponseResult delUserLikes(Integer informationId,Integer userId){
        return informationService.delUserLikes(informationId,userId);
    }

}
